package cn.wbu.zyh.service.impl;

import cn.wbu.zyh.dto.ArticleDTO;
import cn.wbu.zyh.dto.TeamArticleDTO;
import cn.wbu.zyh.entity.TeamArticle;
import cn.wbu.zyh.mapper.TeamArticleMapper;
import cn.wbu.zyh.service.TeamArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeamArticleServiceImpl implements TeamArticleService {
    @Autowired
    public TeamArticleMapper teamArticleMapper;
    @Override
    public void addCollaborator(ArticleDTO articleDTO) {
        List<TeamArticle> teamArticleList = articleDTO.getTeamArticle();
        // 保存协作者信息
        if (articleDTO.getTeamArticle() != null) {
            for (TeamArticle teamArticle : teamArticleList) {
                //User user = userMapper.findByUsername(collaborator.getUserName());
//                if (user != null) {
//                    collaboratorMapper.addCollaborator(articleDTO.getId(), user.getId(), collaborator.getPermission());
//                }
                teamArticleMapper.addCollaborator(teamArticle);
            }
        }
    }
}
